package www.hz.domain.strategy.service.rule.chain.impl;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import www.hz.domain.strategy.service.armory.IStrategyDispatch;
import www.hz.domain.strategy.service.rule.chain.AbstractLogicChain;
import www.hz.domain.strategy.service.rule.chain.factory.DefaultChainFactory;

import javax.annotation.Resource;

/**
 * @className: DefaultLogicChain
 * @Description: TODO
 * @version: v1.８.0
 * @author: hz
 * @date: 2025/3/16 9:37
 */
@Slf4j
@Component("default")
public class DefaultLogicChain extends AbstractLogicChain {

    @Resource
    protected IStrategyDispatch strategyDispatch;
    @Override
    public String ruleModel() {
        return "default";
    }

    @Override
    public DefaultChainFactory.StrategyAwardVO logic(String userId, Long strategyId) {
        Integer awardId = strategyDispatch.getRandomAwardId(strategyId);
        log.info("抽奖责任链-默认处理 userId: {} strategyId: {} ruleModel: {} awardId: {}", userId, strategyId, ruleModel(), awardId);
        return DefaultChainFactory.StrategyAwardVO.builder().awardId(awardId).logicModel(DefaultChainFactory.LogicModel.RULE_DEFAULT.getCode()).build();
    }
}